//!@Author: DengLibin
//!@Date: Create in 2025-05-13 13:38:45
//!@Description: 
mod test {
    use my_util_lib::log_util;
    use rust_my_tools::{dao::mysql::mysql_dao, entity::article::Article};

    use tokio::runtime::Builder;
    fn cre_runtime() -> tokio::runtime::Runtime {
        // 创建一个 Tokio 运行时，配置线程池的大小
        Builder::new_multi_thread()
            .worker_threads(1) // 设置工作线程的数量
            .max_blocking_threads(16) // 设置阻塞任务的最大线程数
            .enable_all()
            .build()
            .unwrap()
    }
    #[test]
    pub fn test_scroll(){
        log_util::init_log("log4rs.yaml").unwrap();
        let r = cre_runtime();
        let _ = r.block_on(async{
            log::info!("开始");
            let pool = mysql_dao::get_conn_pool("mysql://denglibin:denglibin@192.168.6.231:3307/yuqing_data", 5).await?;
            log::info!("获取数据库连接成功");
            mysql_dao::scroll_all::<Article>(100, &pool, |rows| {
                for row in rows.iter() {
                    println!("{:?}", row);
                }
                return true;
            }).await
        }).unwrap();

        println!("完成");
    }

    #[test]
    pub fn test_select(){
        log_util::init_log("log4rs.yaml").unwrap();
        let r = cre_runtime();
        let datas = r.block_on(async{
            log::info!("开始");
            let pool = mysql_dao::get_conn_pool("mysql://denglibin:denglibin@192.168.6.231:3307/yuqing_data", 5).await?;
            log::info!("获取数据库连接成功");
            mysql_dao::select_list("select * from bid_com limit 10", &pool).await
        }).unwrap();

        println!("表头:\n{:?}", datas.0);
        println!("数据:\n");
        for row in datas.1 {
            println!("{:?}", row);
            println!("");
            println!("");
            println!("");
        }

    }
}